﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;

namespace FIM
{
    public class MouseButton : SingleInput
    {
        public override bool IsPressed
        {
            get { return IsDown && getBtnState(manager.PreviousMouse) == ButtonState.Released; }
        }
        public override bool IsReleased
        {
            get { return IsUp && getBtnState(manager.PreviousMouse) == ButtonState.Pressed; }
        }
        public override bool IsDown
        {
            get { return getBtnState(manager.CurrentMouse) == ButtonState.Pressed && manager.Game.IsActive; }
        }
        public override bool IsUp
        {
            get { return getBtnState(manager.CurrentMouse) == ButtonState.Released || !manager.Game.IsActive; }
        }
        public override float Value
        {
            get { return IsDown ? 1 * mul : 0; }
        }
        MouseBtnName button;

        public MouseButton(CManager inputManager, MouseBtnName theButton)
            : this(inputManager, 1, theButton) { }

        public MouseButton(CManager inputManager, float multiplier, MouseBtnName theButton)
            : base(inputManager, multiplier)
        {
            button = theButton;
        }

        private ButtonState getBtnState(MouseState mouseState)
        {
            switch (button)
            {
                case MouseBtnName.LeftBtn: return mouseState.LeftButton;
                case MouseBtnName.MiddelBtn: return mouseState.MiddleButton;
                case MouseBtnName.RightBtn: return mouseState.RightButton;
                case MouseBtnName.ExtraBtn1: return mouseState.XButton1;
                case MouseBtnName.ExtraBtn2: return mouseState.XButton2;
                default: return ButtonState.Released;
            }
        }
    }
}
